import request from '@/utils/request'
export const getEmployeeList = (params) => {
  return request.get('/sys/user', { params })
}
// 导出员工数据
/**
 * 导出员工的excel
 * **/

export const exportEmployee = () => {
  return request({
    url: '/sys/user/export',
    // 改变接收数据的类型
    responseType: 'blob' // 使用blob接收二进制文件流
  })
}
// 员工模板
export const importTemplate = () => {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob'
  })
}
// 上传
export const importExcel = (data) => {
  return request.post('/sys/user/import', data)
}
// 删除
export const delEmployee = (id) => {
  return request.delete(`/sys/user/${id}`)
}
// 新增
// export const addEmployee = (data) => {
//   return request.post('/sys/user', data)
// }
export function addEmployee(data) {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}
// 查看员工详情
export const getEmployeeDetail = (id) => {
  return request.get(`/sys/user/${id}`)
}
// 更新员工
export const updateEmployee = (data) => {
  return request.put(`/sys/user/${data.id}`, data)
}
// 获取可用角色
export const getEnaleList = () => {
  return request.get('/sys/role/list/enabled')
}
// 分配员工角色
export const assignRole = (data) => {
  return request.put('/sys/user/assignRoles', data)
}
